$(document).ready(function () {
    //试题分类隐藏“无”
    var area = $("#area").val();
    if (area == '试题分类') {
        $("#cmbProvince").hide();
        $("#cmbCity").hide();
        $("#cmbArea").hide();
    } else {
        $("#cmbProvince").show();
        $("#cmbCity").show();
        $("#cmbArea").hide();
    }


    $(".examinationClassify").hide();
    $("#patternClassify").change(function () {
        var patternClassify = $('#patternClassify option:selected').text();
        if (patternClassify == '第一站问答') {
            $(".examinationClassify").hide();
            $("#wdExaminationClassifyAll").show();
        }
        if (patternClassify == '第二站常规化' || patternClassify == '第二站客观化') {
            $(".examinationClassify").hide();
            $("#nomalAndObjectiveExaminationClassifyParentAll").show();
        }
    });
    $("#nomalAndObjectiveExaminationClassifyParent").change(function () {
        var nomalAndObjectiveExaminationClassifyParent = $('#nomalAndObjectiveExaminationClassifyParent option:selected').text();
        if (nomalAndObjectiveExaminationClassifyParent == '穴位定位') {
            $(".examinationClassify").hide();
            $("#nomalAndObjectiveExaminationClassifyParentAll").show();
            $("#nomalAndObjectiveExaminationClassifyChild1All").show();
        }
        if (nomalAndObjectiveExaminationClassifyParent == '单项手法') {
            $(".examinationClassify").hide();
            $("#nomalAndObjectiveExaminationClassifyParentAll").show();
            $("#nomalAndObjectiveExaminationClassifyChild2All").show();
        }
        if (nomalAndObjectiveExaminationClassifyParent == '整套手法') {
            $(".examinationClassify").hide();
            $("#nomalAndObjectiveExaminationClassifyParentAll").show();
            $("#nomalAndObjectiveExaminationClassifyChild3All").show();
        }
    });

});


//试题分类搜索连级
var addressInit = function (_carea, _cmbProvince, _cmbCity, _cmbArea, defaultarea1, defaultProvince, defaultCity, defaultArea) {
    var area = document.getElementById(_carea);
    var cmbProvince = document.getElementById(_cmbProvince);
    var cmbCity = document.getElementById(_cmbCity);
    var cmbArea = document.getElementById(_cmbArea);

    function cmbSelect(cmb, str) {
        for (var i = 0; i < cmb.options.length; i++) {
            if (cmb.options[i].value == str) {
                cmb.selectedIndex = i;
                return;
            }
        }
    }

    function cmbAddOption(cmb, str, obj) {
        var option = document.createElement("OPTION");
        option.innerHTML = str;
        option.value = str;
        option.obj = obj;
        cmb.options.add(option);
    }

    function changeCity() {
        cmbArea.options.length = 0;
        if (cmbCity.selectedIndex == -1) return;
        var item = cmbCity.options[cmbCity.selectedIndex].obj;
        for (var i = 0; i < item.areaList.length; i++) {
            cmbAddOption(cmbArea, item.areaList[i], null);
        }
        cmbSelect(cmbArea, defaultArea);
    }

    function changeProvince() {
        cmbCity.options.length = 0;
        cmbCity.onchange = null;
        if (cmbProvince.selectedIndex == -1) return;

        var item = cmbProvince.options[cmbProvince.selectedIndex].obj;
        for (var i = 0; i < item[cmbProvince.selectedIndex].cityList.length; i++) {
            cmbAddOption(cmbCity, item[cmbProvince.selectedIndex].cityList[i].name, item[cmbProvince.selectedIndex].cityList[i]);
        }
        cmbSelect(cmbCity, defaultCity);
        changeCity();
        cmbCity.onchange = changeCity;
    }

    function changeArea() {
        cmbProvince.options.length = 0;
        cmbProvince.onchange = null;
        if (area.selectedIndex == -1) return;
        var item = area.options[area.selectedIndex].obj;
        for (var i = 0; i < item.Allcity.length; i++) {
            cmbAddOption(cmbProvince, item.Allcity[i].name, item.Allcity);
        }
        cmbSelect(cmbProvince, defaultProvince);
        changeProvince();
        cmbProvince.onchange = changeProvince;
    }

    for (var i = 0; i < provinceList.length; i++) {
        cmbAddOption(area, provinceList[i]._area, provinceList[i]);
    }

    cmbSelect(area, defaultarea1);
    changeArea();
    area.onchange = changeArea;
}

var provinceList = [
    {
        _area: "试题分类",
        Allcity: [{
            name: '无',
            cityList: [{
                name: '无',
                areaList: ['无']
            }]
        }
        ]
    },
    {
        _area: "第一站问答",
        Allcity: [{
            name: '全部',
            cityList: [{
                name: '无',
                areaList: ['无']
            }]
        }, {
            name: '腧穴试题',
            cityList: [{
                name: '无',
                areaList: ['无']
            }]
        },
            {
                name: '伤科按摩学',
                cityList: [{
                    name: '无',
                    areaList: ['无']
                }]
            },
            {
                name: '妇科按摩学',
                cityList: [{
                    name: '无',
                    areaList: ['无']
                }]
            },
            {
                name: '内科按摩学',
                cityList: [{
                    name: '无',
                    areaList: ['无']
                }]
            },
            {
                name: '儿科推拿学',
                cityList: [{
                    name: '无',
                    areaList: ['无']
                }]
            }

        ]
    },
    {
        _area: "第二站常规化",
        Allcity: [{
            name: '全部',
            cityList: [{
                name: '无',
                areaList: ['无']
            }]
        }, {
            name: '穴位定位',
            cityList: [{
                name: '全部',
                areaList: ['无']
            }, {
                name: '成人穴位',
                areaList: ['无']
            }, {
                name: '儿科穴位',
                areaList: ['无']
            }]
        }, {
            name: '单项手法',
            cityList: [{
                name: '全部',
                areaList: ['无']
            }, {
                name: '成人手法',
                areaList: ['无']
            }, {
                name: '儿科手法',
                areaList: ['无']
            }]
        }, {
            name: '整套手法',
            cityList: [{
                name: '全部',
                areaList: ['无']
            }, {
                name: '伤科',
                areaList: ['无']
            }, {
                name: '妇科',
                areaList: ['无']
            }, {
                name: '儿科',
                areaList: ['无']
            }, {
                name: '内科',
                areaList: ['无']
            }]
        }

        ]
    }, {
        _area: "第二站客观化",
        Allcity: [{
            name: '全部',
            cityList: [{
                name: '无',
                areaList: ['无']
            }]
        }, {
            name: '穴位定位',
            cityList: [{
                name: '无',
                areaList: ['无']
            }]
        }, {
            name: '单项手法',
            cityList: [{
                name: '全部',
                areaList: ['无']
            }, {
                name: '挤压类',
                areaList: ['无']
            }, {
                name: '摆动类',
                areaList: ['无']
            }, {
                name: '叩击类',
                areaList: ['无']
            }, {
                name: '振动类',
                areaList: ['无']
            }, {
                name: '摩擦类',
                areaList: ['无']
            }]
        },

            {
                name: '整套手法',
                cityList: [{
                    name: '全部',
                    areaList: ['无']
                },{
                    name: '伤科',
                    areaList: ['无']
                }, {
                    name: '妇科',
                    areaList: ['无']
                }, {
                    name: '儿科',
                    areaList: ['无']
                }, {
                    name: '内科',
                    areaList: ['无']
                }]
            }

        ]
    }

];


//试题分类隐藏“无”
function selectChange() {
    var cmbProvince = $("#cmbProvince").val();
    var cmbCity = $("#cmbCity").val();
    var cmbArea = $("#cmbArea").val();
    if (cmbProvince == "无") {
        $("#cmbProvince").hide();
    } else {
        $("#cmbProvince").show();
    }
    if (cmbCity == "无") {
        $("#cmbCity").hide();
    } else {
        $("#cmbCity").show();
    }
    if (cmbArea == "无") {
        $("#cmbArea").hide();
    } else {
        $("#cmbArea").show();
    }
}

